//
// CrackError
//
// Copyright (C) jextra.net.
//
//  This file is part of the Crack build system.
//
//  The Crack build system is free software; you can redistribute it 
//  and/or modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  The Crack build system is distributed in the hope that it will be 
//  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with the Crack build system; if not, write to the Free
//  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
//  02111-1307 USA.
//

package net.jextra.crack;


/**
 * <p>
 * A CrackError is a non-stacktraced error displayed to the user.
 * </p>
 */
public class CrackError extends CrackException
{
    // ============================================================
    // Fields
    // ============================================================

    private String message;

    // ============================================================
    // Constructors
    // ============================================================

    public CrackError( String message )
    {
        super( message );
        setMessage( message );
    }

    public CrackError( String format, Object ...args )
    {
        super( String.format( format, args ) );
        setMessage( String.format( format, args ) );
    }

    public CrackError( String message, Throwable ex )
    {
        super( message, ex );
        setMessage( message );
    }

    public CrackError( Throwable ex )
    {
        super( ex );
        setMessage( ex.getMessage() );
    }

    // ============================================================
    // Methods
    // ============================================================

    // ----------
    // public
    // ----------

    @Override
    public String getMessage()
    {
        return message;
    }

    public void setMessage( String message )
    {
        this.message = message;
    }

    public void print()
    {
        System.err.println( "\n <ERROR> " + getMessage() + "\n" );
    }

    @Override
    public String toString()
    {
        return "\n <ERROR> " + getMessage() + "\n";
    }
}

